/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class CreateCineData {
	public void createTestData() throws PersistentException {
		PersistentTransaction t = orm.CinePersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.PeliculaDAO lormPeliculaDAO = lDAOFactory.getPeliculaDAO();
			orm.Pelicula lormPelicula = lormPeliculaDAO.createPelicula();
			// TODO Initialize the properties of the persistent object here, the following properties must be initialized before saving : sala
			lormPeliculaDAO.save(lormPelicula);
			orm.dao.GeneroDAO lormGeneroDAO = lDAOFactory.getGeneroDAO();
			orm.Genero lormGenero = lormGeneroDAO.createGenero();
			// Initialize the properties of the persistent object here
			lormGeneroDAO.save(lormGenero);
			orm.dao.ClasificacionDAO lormClasificacionDAO = lDAOFactory.getClasificacionDAO();
			orm.Clasificacion lormClasificacion = lormClasificacionDAO.createClasificacion();
			// Initialize the properties of the persistent object here
			lormClasificacionDAO.save(lormClasificacion);
			orm.dao.SalaDAO lormSalaDAO = lDAOFactory.getSalaDAO();
			orm.Sala lormSala = lormSalaDAO.createSala();
			// TODO Initialize the properties of the persistent object here, the following properties must be initialized before saving : pelicula
			lormSalaDAO.save(lormSala);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			CreateCineData createCineData = new CreateCineData();
			try {
				createCineData.createTestData();
			}
			finally {
				orm.CinePersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
